class_name GoldUI
extends HBoxContainer

@export var run_stats: RunStats: set = _set_run_stats
@onready var label: Label = $Label

func _set_run_stats(value: RunStats) -> void:
	run_stats = value
	if not run_stats.gold_changed.is_connected(_update_gold):
		run_stats.gold_changed.connect(_update_gold)
		_update_gold()
	
func _update_gold() -> void:
	label.text = str(run_stats.gold)
